# -*- coding: utf-8 -*-
# Created by shu2015626 on 2019-7-11
"""
需要动态配置的，更新交易日历的任务.
这个这里写完就可以了，然后到后台配置这个文件和类名
不用到tasks.py里配置任务了
"""

import os
import time

import tushare as ts
from django.conf import settings

from apps.BusinessBase import BusinessBase


class BusinessUpdateTradeCal(BusinessBase):
    def run(self):
        df = ts.trade_cal()
        filename = 'trade_cal_' + time.strftime('%Y%m%d_%H%M%S', time.localtime()) + ".csv"
        file_path = os.path.join(settings.BASE_DIR, f"test/data/{filename}")
        df.to_csv(file_path)


if __name__ == "__main__":
    obj = BusinessUpdateTradeCal()
    obj.run()
